package net.m2technologies.open_arm.tranreport;

import net.m2technologies.open_arm.transaction.ArmApplicationDefinitionImpl;
import net.m2technologies.open_arm.transaction.ArmTransactionDefinitionImpl;
import net.m2technologies.open_arm.transaction.ArmTransactionFactoryImpl;
import net.m2technologies.open_arm.transport.TransportMediatorBroker;
import org.opengroup.arm40.tranreport.ArmApplicationRemote;
import org.opengroup.arm40.tranreport.ArmSystemAddress;
import org.opengroup.arm40.tranreport.ArmTranReport;
import org.opengroup.arm40.tranreport.ArmTranReportFactory;
import org.opengroup.arm40.transaction.ArmApplication;
import org.opengroup.arm40.transaction.ArmApplicationDefinition;
import org.opengroup.arm40.transaction.ArmID;
import org.opengroup.arm40.transaction.ArmTransactionDefinition;

/**
 * Copyright 2005 Mark Masterson<br> <br> Licensed under the Apache License, Version 2.0 (the "License");<br> you may
 * not use this file except in compliance with the License.<br> You may obtain a copy of the License at<br> <br>
 * http://www.apache.org/licenses/LICENSE-2.0<br> <br> Unless required by applicable law or agreed to in writing,
 * software<br> distributed under the License is distributed on an "AS IS" BASIS,<br> WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied.<br> See the License for the specific language governing permissions and<br>
 * limitations under the License.<br>
 * <p/>
 * <p>Description: </p>
 *
 * @author Mark Masterson
 * @version 0.010
 */
public class ArmTranReportFactoryImpl extends ArmTransactionFactoryImpl implements ArmTranReportFactory {

    public ArmTranReportFactoryImpl(final TransportMediatorBroker transportMediatorBroker) {
        super(transportMediatorBroker);
    }


    public ArmApplicationRemote newArmApplicationRemote(final ArmApplicationDefinition definition,
                                                        final String group,
                                                        final String instance,
                                                        final String[] contextValues,
                                                        final ArmSystemAddress systemAddress) {
        return ((ArmApplicationDefinitionImpl) definition).getRemoteApplication(contextValues,
                                                                                group,
                                                                                instance,
                                                                                this,
                                                                                systemAddress);
    }

    public ArmSystemAddress newArmSystemAddress(final short format, final byte[] addressBytes, final ArmID id) {
        return new ArmSystemAddressImpl(addressBytes, this, format, id);
    }

    public ArmSystemAddress newArmSystemAddress(final short format,
                                                final byte[] addressBytes,
                                                final int offset,
                                                final ArmID id) {
        throw new UnsupportedOperationException(
                "This signature is just too stupid to contemplate. Damn C programmers.");
    }

    public ArmSystemAddress newArmSystemAddress(final short format,
                                                final byte[] addressBytes,
                                                final int offset,
                                                final int length,
                                                final ArmID id) {
        throw new UnsupportedOperationException(
                "This signature is just too stupid to contemplate. Damn C programmers.");
    }

    public ArmTranReport newArmTranReport(final ArmApplication app, final ArmTransactionDefinition definition) {
        final ArmTranReport result = ((ArmTransactionDefinitionImpl) definition).getTransactionReport(this);
        return result;
    }

}
